#ifndef SPEED_CTRL_H
#define SPEED_CTRL_H
#include "tp_type.h"
//#include "quintic.h"

typedef struct{
	double target;				//target travel
	double progress;				//travel progress
	float current_vel;			//current vel
	float current_acc;			//

	//---------------
	float req_max_vel;			//request velocity
	float req_acca;				//request accelration
	float req_accd;				//request accelration
	float req_start_vel;		//request start vel
	float req_stop_vel;			//request stop vel

	//----------------
	float target_vel;			//velocity to actually track, limited by other factors
	float finalvel;				//velocity to aim for at end of segment
	float term_vel;				//actual velocity at termination of segment
	char on_final_decel;		//deceleraton velocity
	float real_target_vel;
	float real_final_vel;
	float real_accel;

	//-----------------
	char active;				//active this control
	char split;					//split segment
}STRUCT_SPEED_CTRL;

//====================================
void spClear(STRUCT_SPEED_CTRL *vl);
void spActive(STRUCT_SPEED_CTRL *vl,char is_active);
void spCalculateTrapezoidalAccel(STRUCT_SPEED_CTRL *vl, float *vel_desired);
int spUpdateDistFromAccel(STRUCT_SPEED_CTRL *vl, float vel_desired);


#endif // SPEED_CTRL_H
